class Solution108 {
    public static void main(String[] args) {
        Solution108 solution108 = new Solution108() ;
        int [] arr = {-10,-3,0,5,9} ;
        solution108.getTree(arr , 0 , arr.length-1);
    }
    class TreeNode {
      int val;
      TreeNode left;
      TreeNode right;
      TreeNode() {}
      TreeNode(int val) { this.val = val; }
      TreeNode(int val, TreeNode left, TreeNode right) {
          this.val = val;
          this.left = left;
          this.right = right;
      }
  }
    public TreeNode sortedArrayToBST(int[] nums) {
        return getTree(nums , 0 , nums.length-1) ; 
    }
    private TreeNode getTree(int[] nums , int left , int right){
        if(left > right) return null ;
        
        int mid = left+(right-left)/2 ;
        TreeNode root = new TreeNode(nums[mid]) ; 
            root.left = getTree(nums , left , mid-1) ; 
            root.right = getTree(nums , mid+1 , right) ; 
        return root ;
    }
}